<?php
/**
 * CURL封装类
 * @copyright reginx.com
 * $Id: curl.lib.php 146 2013-01-22 09:59:59Z reginx.com@gmail.com $
 */
class curl_lib {
    /**
     * UA
     *
     * @var unknown_type
     */
    static $ua  = 'Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1) Chrome/14.0.835.202';

    /**
     * 引用地址
     *
     * @var unknown_type
     */
    static $ref = 'http://www.baidu.com';

    /**
     * ip
     *
     * @var unknown_type
     */
    static $ip  = '60.28.17.47';

    /**
     * 抓取远程图片
     *
     * @param unknown_type $url
     */
    static function &get($url){
        $s = curl_init();
        curl_setopt($s , CURLOPT_URL , $url);
        curl_setopt($s , CURLOPT_TIMEOUT , 5);
        curl_setopt($s , CURLOPT_RETURNTRANSFER , 1);
        curl_setopt($s , CURLOPT_REFERER     , self::$ref);
        curl_setopt($s , CURLOPT_USERAGENT   , self::$ua);
        curl_setopt($s , CURLOPT_HTTPHEADER  , self::getHeaders());
        $ret = curl_exec($s);
        curl_close($s);
        return $ret;
    }

    static function getHeaders(){
        $ip = mt_rand(90 ,  90).'.'.mt_rand(20 ,  90).'.'.mt_rand(20 ,  90).'.'.mt_rand(20 ,  90);
        return array('X-FORWARDED-FOR:'.$ip , 'CLIENT-IP:'.$ip  ,  'REMOTE-ADDR:' . $ip);
    }
}

?>